package com.dragon.client.controller.avttendance;

import com.dragon.common.model.ResponseData;
import com.dragon.logical.service.avttendance.IArrangePersonnelService;
import com.dragon.repository.domain.dto.ArrangePersonnelDTO;
import com.dragon.repository.domain.vo.ArrangePersonnelVO;
import com.dragon.repository.entity.ArrangePersonnel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 考勤配置人员关联 前端控制器
 * </p>
 *
 * @author sy
 * @since 2023-07-31
 */
@RestController
@RequestMapping("arrangePersonnel")
@Api(tags = "考勤人员")
public class ArrangePersonnelController {

    @Autowired
    IArrangePersonnelService service;

    @GetMapping("list")
    @ApiOperation("获取考勤人员列表")
    public ResponseData<List<ArrangePersonnelDTO>> personnelList(Integer arrangeId){
        List<ArrangePersonnel> personnels = service.personnelLis(arrangeId);
        return ResponseData.success(ArrangePersonnelDTO.convertList(personnels));
    }

    @PostMapping("add")
    @ApiOperation("添加人员配置")
    public ResponseData personnelAdd( @RequestParam(required = false) Integer arrangeId, @RequestBody ArrangePersonnelVO vo){
        service.personnelAdd(arrangeId,ArrangePersonnelVO.convert(vo));
        return ResponseData.success();
    }

    @PostMapping("delete")
    @ApiOperation("删除人员配置")
    public ResponseData personnelDelete(Integer id) {
        service.personnelDelete(id);
        return ResponseData.success();
    }

}
